package com.song.ssm.month.web;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import java.sql.SQLException;

/**
 * @Author 宋伟宁
 * @Date 2023/9/25
 * @Version 1.0
 **/
@ControllerAdvice
public class MyException {

    @ExceptionHandler(SQLException.class)
    public String sqlHandle(SQLException e, Model model){
          model.addAttribute("mess","sql异常！！！！");
          return "sql-err";
    }
    @ExceptionHandler(NullPointerException.class)
    public String nullHandle(NullPointerException e, Model model){
        model.addAttribute("mess","空指针异常！！！！");
        return "null-err";
    }

}
